#ifndef  __SAVE_H
#define  __SAVE_H

//----------------------------------Include-------------------------------------
#include <stdint.h>
//------------------------------------------------------------------------------

//-----------------------------------Macro--------------------------------------
#define SAVE_START_ADDR          (0x0000)
#define SAVE_END_ADDR            (0x8000)
//------------------------------------------------------------------------------
#define SAVE_EXIST_CH4           (1<<0)
#define SAVE_EXIST_T             (1<<16)
#define SAVE_EXIST_RH            (1<<17)
#define SAVE_EXIST_IMMER         (1<<18)
#define SAVE_EXIST_ACC           (1<<19)
#define SAVE_EXIST_BAT           (1<<24)
#define SAVE_EXIST_NB            (1<<25)
#define SAVE_EXIST_GPS           (1<<26)
//------------------------------------------------------------------------------

//------------------------------------Type--------------------------------------
typedef struct{
  uint32_t         ver;
  uint32_t         exist;

  uint16_t         dev_type;
  uint16_t         warn_ch4;        //*100
  uint16_t         early_ch4;       //*100
  uint16_t         low_temp;        //(+100)*10
  uint16_t         high_temp;       //(+100)*10
  uint16_t         low_bat;         //*100

  uint16_t         snsr_frq_min;    //min
  uint16_t         data_up_frq_min; //min
  uint16_t         cfg_up_frq_hr;   //hour
  uint16_t         gps_up_frq_day;  //day
  uint16_t         cnct_frq_hr;     //hour
  uint16_t         ipport;
  
  uint32_t         ipv4;
  uint32_t         dev_addr;

  uint32_t         pswd_user;
  uint32_t         pswd_root;

  uint16_t         u16check;
  uint16_t         u16InitWd;
}t_save_dev;
//------------------------------------------------------------------------------

//---------------------------------Global Var-----------------------------------
#ifdef  SAVE_GLOBALS
#else
extern  t_save_dev           sgt_dev;
#endif
//------------------------------------------------------------------------------

//-----------------------------------Declare------------------------------------
uint32_t save_dev_write(void);
void     save_dev_read(void);
void     save_dev_reset(void);
//------------------------------------------------------------------------------

#endif
//-------------------------------------EOF--------------------------------------
